﻿using System;
using System.ComponentModel;
using System.Diagnostics;
using NHibernate.Validator.Constraints;

namespace DataStore.Domain
{
    /// <summary>
    /// Document keywords
    /// </summary>
    [Serializable]
    public class Keyword : IDataErrorInfo
    {
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        public virtual Guid Id { get; set; }
        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        /// <value>The text.</value>
        [NotNullNotEmpty]
        public virtual string Text { get; set; }

        #region IDataErrorInfo Members

        string IDataErrorInfo.Error
        {
            get { return null; }
        }

        string IDataErrorInfo.this[string columnName]
        {
            get { return GetValidationError(columnName); }
        }

        #endregion


        protected virtual string GetValidationError(string propertyName)
        {
            if (Array.IndexOf(_validatedProperties, propertyName) < 0)
                return null;

            string error = string.Empty;

            switch (propertyName)
            {
                default:
                    Debug.Fail("Unexpected property being validated on CatalogItem: ", propertyName);
                    break;
            }

            return error;
        }

        readonly string[] _validatedProperties =
        {
            
        };

        public virtual bool IsValid
        {
            get
            {
                foreach (string property in _validatedProperties)
                {
                    if (GetValidationError(property) != string.Empty)
                    {
                        return false;
                    }
                }

                return true;
            }
        }
    }
}
